#!/usr/bin/env bash

# set -e: exit asap if a command exits with a non-zero status
set +e

echo "#======================="
echo "# Scenario 0: Unit tests"
echo "#======================="

# Due to the dependency GNU sed, we're skipping this part when running
# on Mac OS X.
# https://github.com/SeleniumHQ/docker-selenium/blob/master/test.sh#L12
if [ "$(uname)" != 'Darwin' ]; then
  echo 'Testing shell functions...'
  which bats >/dev/null 2>&1
  if [ $? -ne 0 ] ; then
    echo "Could not find 'bats'. Please install it first, e.g., following https://github.com/sstephenson/bats#installing-bats-from-source."
    exit 1
  fi
  ./test/test-functions.sh || exit 1
else
  echo 'Skipping shell functions test on Mac OS X.'
fi
